﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MaxLeaf.Platform.Contract;
using MaxLeaf.Platform.BLLImplementation;
using CommonsLib.Utility;
using MaxLeaf.Platform.DataContract;
using CommonsLib.Settings;
using MaxLeaf.Platform.Functions;

namespace MaxLeaf.Platform.BLLProxy
{

    /// <summary>
    /// 商品 相关操作
    /// </summary>
    public class GoodsProcessorProxy : BaseBLLProxy, IGoodsProcess
    {

        IGoodsProcess _bll;
        private  IGoodsProcess BLL
        {
            get
            {                
                return _bll;
            }
        }
        public GoodsProcessorProxy():base()
        {
            switch ( Access_Mode )
            {

                case MaxLeaf.Platform.Commons.Const.ACCESS_Direct:
                    {
                        _bll = new GoodsProcessor();
                        break;
                    }

                case MaxLeaf.Platform.Commons.Const.ACCESS_IIS:
                    {
                        _bll = new GoodsProcessorWCFClient(this.WCF_Configs);
                        break;
                    }


                default:
                    {
                        throw new MaxLeaf.Platform.Commons.MaxLeafException(MaxLeaf.Platform.Commons.Const.EXCEPTION_MESSAGE_INVALID_ACCESSMODE_CONFIG);

                    }
            }
        }
        /// <summary>
        /// 获得当前单位往库存单位的转换率
        /// </summary>
        /// <param name="intGoodsID">商品id</param>
        /// <param name="intUnitID">单位id</param>
        /// <returns>转换率</returns>
        public double GetRate(int intGoodsID, int intUnitID )
        {
            return BLL.GetRate(intGoodsID, intUnitID);
        }

        /// <summary>
        /// 获得php网站价格
        /// </summary>
        /// <param name="intGoodsID">商品id</param>
        /// <param name="intUnitID">单位id</param>
        /// <param name="intAreaID">区域ID</param>
        /// <param name="intUserID">用户id</param>
        /// <param name="intPriceType">0:网站价格,1:协议价格</param>
        /// <returns>价格</returns>
        public double GetWebPrice(int intGoodsID, int intUnitID, int intAreaID, int intUserID, int intPriceType)
        {
            return BLL.GetWebPrice(  intGoodsID,   intUnitID,   intAreaID,   intUserID,  intPriceType);
        }

        ///// <summary>
        ///// 返回一个公司的 没有加入库存的商品
        ///// </summary>
        ///// <param name="intCompanyID">公司id</param>
        ///// <param name="intGoodsID">指定商品id，如果为0则是所有商品</param>
        ///// <returns>没有加入库存的商品列表</returns>
        //public List<ImInvMasterDataModel> GetNoInvLocItems(int intCompanyID, int intGoodsID)
        //{
        //    return BLL.GetNoInvLocItems(intCompanyID,intGoodsID);
        //}

        /// <summary>
        /// 传入用户ID 和商品ID 可以查到自定义类别的信息
        /// </summary>
        /// <param name="intUserID">用户ID</param>
        /// <param name="intGoodsID">商品ID</param>
        ///<param name="blnTop"> 是当前商品所在类别还是最上级类别</param>
        /// <returns></returns>
        public SCPCategoryDataModel GetSCPCategory(int intUserID, int intGoodsID,bool blnTop)
        {
            return BLL.GetSCPCategory(intUserID, intGoodsID,  blnTop);
        }

        /// <summary>
        /// 得到对应SCPCategroy的所有GoodsCategory
        /// </summary>
        /// <param name="intCompanyID">公司id</param>
        /// <param name="intSCPCategoryID">SCPCategroy id</param>
        /// <returns>GoodsCategory列表,排序 cat_level,sort_order,parent_id,cat_id</returns>
        public List<goods_categoryDataModel> GetGoodCateGoryBySCPCategory(int intCompanyID, int intSCPCategoryID)
        {
            return BLL.GetGoodCateGoryBySCPCategory(intCompanyID, intSCPCategoryID);
        }

        
        /// <summary>
        /// 按照编码规则得到自定义编码
        /// </summary>
        /// <param name="intCompanyID">CompanyID</param>
        /// <param name="strStKeywords">起始编码</param>
        /// <param name="intCount">个数</param>
        /// <returns>编码列表</returns>
        public List<string> GetUserKeywords(int intCompanyID, string strStKeywords, int intCount)
        {
            return BLL.GetUserKeywords(  intCompanyID,strStKeywords, intCount);
        }
    }
}
